import { acceptHMRUpdate, defineStore } from "pinia";
import { UserInterface } from "~~/types";

interface userInfoStoreInterface {
  userInfo: UserInterface | null;
}

export const useUserInfo = defineStore("userInfo", {
  state: (): userInfoStoreInterface => {
    return {
      userInfo: null,
    };
  },
  getters: {
    getUserInfo: (state) => state.userInfo,
  },
  actions: {
    setUserInfo(userInfo: UserInterface) {
      this.userInfo = userInfo;
    },
  },
  persist: true,
});

if (import.meta.hot) {
  import.meta.hot.accept(acceptHMRUpdate(useUserInfo, import.meta.hot));
}
